<template>
	<view>
		<view class="root">
			<view class="a">
				<br>
				 <span>更改昵称</span>
				 <br>
				 <input v-model="newname"  type="text" value="" placeholder="新昵称" />
				 <br>
				 <input v-model="password"  type="text" value="" placeholder="密码" />
				 <br>
				 <view class="row">
					 <button @click="qd" type="default">确定</button>
					 <button @click="goto" type="default">取消</button>
				 </view>
				 <br>
				 
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				newname:'',
				password:''
				
			}
		},
		methods: {
			qd(){
				if(this.newname!=''){
					let user
					uni.getStorage({
						key:'name',
						success(res) {
							user=res.data
						}
					})
					
					uni.request({
						url:'http://192.168.1.3:9090/user/updatename',
						method:"POST",
						data:{
							user:user,
							name:this.newname,
							password:this.password
							
						}
					}).then(res=>{
						uni.showToast({
							title:'更改成功，请重新登陆'
						})
						uni.reLaunch({
							
							url:'/pages/login/login'
						})
					})
				}
			},
			goto(){
				uni.reLaunch({
					url:'/pages/wd/wd'
				})
			}
			
		}
	}
</script>

<style>
.root{
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	height: 100vh;
	
}
.a{
	display: flex;
	flex-direction: column;
	background-color: darkgray;
	border-radius: 10rpx;
	width: 60%;
	align-items: center;
}
input{
	background-color: #FFF;
	width: 80%;
}
.row{
	display: flex;
	flex-direction: row;
}
</style>
